home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 February / macformat-034.iso / mac / Shareware City / Developers / Floating.c ƒ / Read Me - Floating.c < prev   
Encoding:
Text File  |  1995-11-24  |  4.8 KB  |  68 lines  |  [ttro/ttxt]

  1.  "Floating.c"
  2.      -John DeWeese-
  3.   jdeweese@sytex.net
  4.  
  5. Background:
  6.  
  7.     Original pascal source code in "Floating.p" by F. Pottier (see his own comments below), Translated into C because I couldn't find the original C code mentioned in his comments below. I have edited the file several times, and I have also included a header file. The changes have been documented at the top of "floating.c"
  8.  
  9. Information:
  10.  
  11.     "floating.c" - easily manage floating windoids in your application.
  12.  
  13.     Originally based on a set of C routines written by Patrick Doane (America OnLine : Patrick5). Later translated into pascal by F. Pottier (pottier@clipper.ens.fr) Thanks go to these two, and also to Troy Gaul for placing his Infinity Windoid in the public domain.
  14.  
  15.     This code is placed in the public domain. It may be used by anybody, for any purposes. It would be kind to give credits to me as well as to the aforementioned people, though. If you experience any problems, or have ideas for enhancements, tell me about it. I can't guarantee I'll spend much time on it, since I'm only a student and not a professional programmer, but I'll definitely look into it.
  16.  
  17. Comments on Usage:
  18.  
  19.     The Window Manager doesn't know about floating windows. To obtain floating windows in a program, one has to handle them 'by hand', which means calling low-level Window Manager routines to place the windows in their correct positions after each event.
  20. The frequently used, and now to be avoided, Window Manager routines are:
  21.         SelectWindow
  22.         CloseWindow
  23.         HideWindow
  24.         ShowWindow
  25.         DisposeWindow
  26.         DragWindow
  27.  
  28.     Those routines don't know about floating windows, so calling them may mix the floating windows among normal windows.
  29. You also have to be careful with GetNewWindow. You can't call GetNewWindow(ID, wStorage, Pointer(-1)) because that
  30. would put the new window in the front. Rather, we call GetNewWindow(ID, wStorage, nil) which places the window in the
  31. back, and then call our home-made routine, SelectTheWindow.
  32.  
  33.     At every point in the program, we maintain three global variables : topFloat, bottomFloat and topWindow.
  34. topFloat holds the top floating window, nil if there is none. Same thing for bottomFloat with the bottom floating window,
  35. and for topWindow with the top regular window. These three global variables, along with the Window Manager's window
  36. list, are enough to handle the behavior of our windows.
  37. Hidden windows are placed behind all others, so they don't count when determining those variables' values.
  38.  
  39.     In order to distinguish between floating windows and regular ones, we choose a different windowKind for the former.
  40.  
  41.     To make hiliting and unhiliting floating windows simpler, I chose to use a WDEF that always draws windoids in a hilited
  42. state (e.g. Infinity Windoid with the Always Hilite option). This way, I don't have to worry at all about it.
  43.  
  44.     A final remark about modeless dialogs : modeless dialogs and floating windows don't go well together. The Dialog Manager
  45. is confused by floating windows. IsDialogEvent and DialogSelect don't work because they use FrontWindow to find the dialog.
  46. It is easy to rewrite a modified version of isDialogEvent. It is already trickier for DialogSelect. Maybe it would be simpler
  47. to use windows with controls instead of modeless dialogs. Or maybe it's possible to have DialogSelect and isDialogEvent
  48. work by patching FrontWindow? If somebody comes up with a good idea on this topic, please tell me about it.
  49.  
  50. Usage (in brief):
  51.  
  52. - Call InitFloats once before opening any windows.
  53. - To create a new window, call GetNewWindow(id, storage, nil). Then call SelectTheWindow if it's a regular window,
  54.    otherwise call MakeFloat.
  55. - To determine whether a given window is a floating one, call isFloating(whichWindow)
  56. - Instead of SelectWindow[and ShowWindow], HideWindow, DisposeWindow, DragWindow, use SelectTheWindow, HideTheWindow,
  57.    DisposeTheWindow and DragTheWindow.
  58. - Upon a receiving a suspend event, you may call HideFloats(), and ShowFloats() when receiving a resume event. However, be
  59.     aware    that these routines have been tested to be buggy on my machine. Instead, I recommend treating floats as normal windows 
  60.     when    showing them or hidin them - use HideTheWindow(). However, keep a global flag which tells which windows should be 
  61.     shown. This    is useful    for activate events so even though the user closes a few floats, the program will not automatically show 
  62.     every one of    them again.
  63. - Instead of calling FrontWindow(), you can read the values of the variables topFloat and topWindow. They should be up-to-date
  64.    at any point in the program.
  65.  
  66. More Info:
  67.  
  68.     Hoping to someday become a masterful Mac Programmer, I've already started on a really promising application frame. If anybody is interested, give me a buzz (jdeweese@sytex.net). It's currently at version 1.0a5 in native PowerPC code. It is easily portable to 68K, too.